﻿using System.IO;

namespace Hosting
{
    public class FlickrStream : MemoryStream
    {
        private FlickrFile _file;

        public FlickrStream(FlickrFile file, bool allowWrite)
        {
            _file = file;
            if(!allowWrite)
            {
                base.Write(_file.Content, 0, _file.Content.Length);
                base.Position = 0;
            }
        }

        public new void Dispose()
        {
            Close();
            base.Dispose();
        }

        public override void Close()
        {
            _file.Content = GetBuffer();
            base.Close();
        }
    }
}
